<?php
/**
	+----------------------------------------------------------
	* ora Product 库文件
	* Author: lan7  E-mail: 7@lan7.net
	* @ora 扩展库文件 2010-10-10
	+----------------------------------------------------------
*/
class pro_lib{
	/**
	 * 获取产品信息
	 *
	 * @param Integer $id
	 * @param boolean $has_alb
	 * @param boolean $has_content
	 * @param boolean $has_attr
	 * @return array
	 */
	public static function getPro($id,$has_alb=false,$has_content=false,$has_attr=false){
		$pro = array();
		$pro = $GLOBALS['db']->getOne("select * from ".tn("product")." where id = $id");
		if(!$pro){
			return false;
		}
		if($has_alb){
			$pro['album'] = $GLOBALS['db']->getAll("select * from ".tn("album")." where alb_type=1 and fk_id = $id");
		}
		if($has_attr){
			$attr = $GLOBALS['db']->getAll("select * from ".tn("pattr")." where p_id = $id");
			if($attr){
				$pro['attr'] = unserialize($attr[0]['attr']);
			}
		}
		if($has_content){
			$content = $GLOBALS['db']->getOne("select content from ".tn("content")." where ctype=1 and fk_id = $id");
			if($content){
				$pro['content'] = $content["content"];
			}
		}
		return $pro;
	}
}
?>